module RanParser (module RanParser) where

import Parsing 
import BrainFuck

p :: Parser String
p = do {
    symbol "抓翀翀！";
    xs <- p;
    return $ ">" ++ xs
} <|> do {
    symbol "抓猫猫！";
    xs <- p;
    return $ "<" ++ xs
} <|> do {
    symbol "啊呜！";
    xs <- p;
    return $ "+" ++ xs
} <|> do {
    symbol "木啊^3^♥";
    xs <- p;
    return $ "-" ++ xs
} <|> do {
    symbol "耶！";
    xs <- p;
    return $ "." ++ xs
} <|> do {
    symbol "学习qwq";
    xs <- p;
    return $ "," ++ xs
} <|> do {
    symbol "抱抱嘛";
    xs <- p;
    return $ "[" ++ xs
} <|> do {
    symbol "要抱抱";
    xs <- p;
    return $ "]" ++ xs
} <|> do {
    symbol "困困啦。。。";
    return ""
}


ranParser :: String -> String -> IO ()
ranParser ranCode inp = do {
    let {
        bfCode = case parse p ranCode of
            [] -> ""
            [(result, _)] -> result
    };
    let { result = eval (bfCode, inp)};
    putStrLn result
}


-- main = do {
--     ranCode <- readFile "sample.ran";
--     let {
--         bfCode = case parse p ranCode of
--             [] -> ""
--             [(result, _)] -> result
--     };
--     writeFile "trans.bf" bfCode
-- }


-- main = do {
--     ranCode <- readFile "sample.ran";
--     let {
--         bfCode = case parse p ranCode of
--             [] -> ""
--             [(result, _)] -> result
--     };
--     let { result = eval (bfCode, "")};
--     putStrLn result
-- }